package friendApi

import (
	"chart.zozoo.net/app/service/friendService"
	"chart.zozoo.net/app/utils/rsp"
	"github.com/gin-gonic/gin"
)

// ApplyAdd 申请添加好友
func ApplyAdd(c *gin.Context) {
	uuid := c.GetString("uuid")
	friendUuid := c.PostForm("uuid")
	if friendUuid == "" {
		rsp.JsonErr(c, rsp.SetMsg("请传入用户ID"))
		return
	}

	if uuid == friendUuid {
		rsp.JsonErr(c, rsp.SetMsg("不能自己添加自己为好友"))
		return
	}

	err := friendService.ApplyAdd(uuid, friendUuid)
	if err != nil {
		rsp.JsonErr(c, rsp.SetMsg(err.Error()))
		return
	}

	rsp.JsonOk(c)
}
